<?php

//TODO: Instantiierungsverhalten wählen - nicht zwangsläufiges laden aller Daten aus der Datenbank
class User
{
  protected static $knownUsers = array();
  
  public static function GetUserById($id)
  {
    $returnUser = null;
    if (isset($knownUsers[$id]))
    {
      $returnUser = $knownUsers[$id];
    }
    else
    {
      $returnUser = new User($id);
    }
    return $returnUser;
  }
  
  

  protected $id = -1;
  protected $knowledgeDomains = null;
  protected $name = '';
  protected $questions = null;
  
  
  public function GetId()
  {
    return $this->id;
  }
  
  
  public function GetKDomains()
  {
    return $this->knowledgeDomains;
  }
  
  
  
  public function GetName()
  {
    return $this->name;
  }
  
  
  public function GetQuestions()
  {
    return $this->questions;
  }
  
  
  function __construct($id, $kDomains = null, $name = null, $questions = null)
  {
    $this->id = $id;
    if ($kDomains == null && $name = null && $questions == null)
    {
      //TODO: User aus Datenbank laden
    }
    else
    {
      $this->name = $name;
      $this->questions = $questions;
      $this->knowledgeDomains = (!is_null($kDomains)) ? $kDomains : new UserKDomain($this);
    }
  }
  
  
  
  public function AskQuestion($kdomain, $title, $text, $askedBy)
  {
    $question = new Question(-1, $title, $text, $kdomain, NULL, $asker, NULL, NULL, NULL, NULL);
  }
  
  
  
  public function AddQuestion($question)
  {
    if ($this->questions == null)
    {
      $this->questions = array();
    }
    $this->questions[] = $question;
  }
  
  
  
  public function GetAvgFeedback()
  {
    
  }
  
  
  

  
  
  
  public function GetTotalNumFeedback()
  {
    foreach ($this->questions as $question)
    {
      
    }
  }
  
  
  
}

?>